<!DOCTYPE >
<html lang="zh-cn">
<head>
    <title>后台管理-认证</title>
    <% include ./partials/head %>
    <script type="text/javascript">
        var aUthentic ={
            operator:function(){
                $(".box-content").on('click','.ok',function(){
                    $this = $(this)
                    if(window.confirm('你确定要将该用户设置为编辑推荐么吗？')){
                        //认证 0通过，1拒绝
                        $.post("/admin/authenticationEdit",{
                            "authenticationId":$this.attr('authId'),
                            "isAuthentic":0
                        },function(json){
                            if(json.code==0){
                                history.go(0) 
                            }else{
                                alert(json.msg);
                            }
                        },'json');
                    }else{
                        //取消
                    }
                }).on('click','.pass',function(){
                    $this = $(this);
                    if(window.confirm('你确定要拒绝该用户的申请吗？')){
                        //拒绝
                        $.post("/admin/authenticationEdit",{
                            "authenticationId":$this.attr('authId'),
                            "isAuthentic":1
                        },function(json){
                            if(json.code==0){
                                history.go(0) 
                            }else{
                                alert(json.msg);
                            }
                        },'json');
                    }else{
                        //取消
                    }
                })
            },
            change:function(){
                var state =window.location.href.split("=")[1];
                $("#authentic-filter option[value='"+state+"']").attr("selected","selected");
                $("#authentic-filter").on("change",function(){
                    var value = $(this).children('option:selected').val(); 
                    window.location.href="/admin/authenticationEdit?status="+value;
                })
            },
            init:function(){
                this.operator();
                this.change();
            }
        }
        $(document).ready(function(){
            aUthentic.init();
        })
    </script>
</head>
<body>
  <header>
    <% include ./partials/header %>
  </header>
  <div class="ch-container">
    <% include ./partials/sidebar %>

    <!-- 页面内容 -->
      <div id="content" class="col-lg-10 col-sm-10">
        <div class="row">
          <div class="box col-md-12">
            <div class="box-inner">
              <div class="box-header well" data-original-title="">
                <div class="control-group">
                  <div class="controls">
                    <label class="control-label" for="selectError">筛选:&nbsp&nbsp&nbsp </label>
                    <select id="authentic-filter">
                        <option value="0">未处理</option>
                        <option value="1">已处理</option>
                        <option value="2">已拒绝</option>
                    </select>
                  </div>
                  
                </div>
              </div>

              <div class="box-content">
                <table class="table table-striped table-bordered bootstrap-datatable datatable responsive">
                  <thead>
                    <tr>
                      <th></th>
                      <th>昵称</th>
                      <th>口袋号</th>
                      <th>联系方式</th>
                      <th>故事</th>
                      <th>申请时间</th>
                      <th>处理状态</th>
                    </tr>
                  </thead>

                  <tbody>
                    <% if (typeof authentications != "undefined") { %>
                      <% authentications.forEach(function(authentication,index) { %>
                        <tr>
                           <td class="center"><%=index%></td>
                            <td class="center"><a href="/admin/userinfo?userId=<%= authentication.get('sponsor').id%>"><%= authentication.get("sponsor").get("nickname") %></a></td>
                            <td class="center"><%= authentication.get("sponsor").get("molianId") %></td>
                            <td class="center"><%= authentication.get("contact")%></td>
                            <td class="center" style="max-width:300px!important"><%= authentication.get("story")%></td>
                            <td class="center"><%=Format(new Date(authentication.createdAt))%></td>
                            <td class="center">
                            <% if(authentication.get("status")==1){ %>
                                <span class="btn">已处理</span>  
                            <% } %>
                            <% if(authentication.get("status")==2){ %>
                                <span class="btn">已拒绝</span>
                            <% } %>
                            <% if(authentication.get("status")==0){ %>
                                <span class="btn btn-success ok " authId=<%=authentication.id%>>
                                  <i class="glyphicon glyphicon-ok icon-white"></i>
                                 通过 
                                </span>
                                <span class="btn btn-danger pass" authId=<%=authentication.id%>>
                                  <i class="glyphicon glyphicon-remove icon-white"></i>
                                 拒绝 
                                </span>
                            <% } %>

                          </td>
                        </tr>
                      <% }) %>
                    <% } %>
                  </tbody>
                </table>
              </div>

            </div>
          </div>
        </div>
      </div>

    </div>
    <% include ./partials/footer %>
  </div>
  <% include ./partials/external %>
</body>
</html>
